;(function(){
	var WindUtil = {};
	/**
	* 获取风向的中英文描述
	* @param angle 风向角度
	*/
	WindUtil.getWindDire = function(direId){
		var windDirName = [{"CH":"北风","EN":"S"}, 
		                    {"CH":"东北风","EN":"SW"},
		                    {"CH":"东风","EN":"W"}, 
		                    {"CH":"东南风","EN":"NW"},
		                    {"CH":"南风","EN":"N"},
		                    {"CH":"西南风","EN":"NE"},
		                    {"CH":"西风","EN":"E"},
		                    {"CH":"西北风","EN":"SE"},
		                    {"CH":"北风","EN":"S"}];
		var wd = null;
		if(!TypeUtil.isUndefined(direId)){
			wd = windDirName[direId];
		} else {
			wd = {"CH":"","EN":""};
		}
		return wd;
	};

	/**
	* 计算16风向
	* @param angle 风向角度
	*/
	WindUtil.calcWindDire = function(angle){
		if(!$.isNumeric(angle*1)){
			return '';
		}
		var index = 0;
        if (angle >=0 && angle < 22.5) {
            index = 8;
        } else if (angle >=22.5 && angle < 67.5) {
            index = 1;
        } else if (angle >=67.5 && angle < 112.5) {
            index = 2;
        } else if (angle >=112.5 && angle < 157.5) {
            index = 3;
        } else if (angle >=157.5 && angle < 202.5) {
            index = 4;
        } else if (angle >=202.5 && angle < 247.5) {
            index = 5;
        } else if (angle >=247.5 && angle < 292.5) {
            index = 6;
        } else if (angle >=292.5 && angle < 337.5) {
            index = 7;
        } else if (angle >=292.5 && angle < 337.5) {
            index = 7;
        } else if (angle >=337.5 && angle < 360) {
            index = 8;
        }
        return index;
	};
	
	WindUtil.getWindPower = function (fs){
		if(fs)
			fs=parseFloat(fs);
		else
			return "";
		if(fs!=0){
			var level=0;
			if(fs > 0 && fs <= 0.2)
				level=0;
			else if(fs >= 0.2 && fs < 1.6)
				level=1;
			else if(fs >= 1.6 && fs < 3.4)
				level=2;
			else if(fs >= 3.4 && fs < 5.4)
				level=3;
			else if(fs >= 5.4 && fs < 8)
				level=4;
			else if(fs >= 8 && fs < 10.8)
				level=5;
			else if(fs >= 10.8 && fs < 13.9)
				level=6;
			else if(fs >= 13.9 && fs < 17.2)
				level=7;
			else if(fs >= 17.2 && fs < 20.8)
				level=8;
			else if(fs >= 20.8 && fs < 24.5)
				level=9;
			else if(fs >= 22.5 && fs < 28.5)
				level=10;
			else if(fs >= 28.5 && fs <= 32.6)
				level=11;
			else if(fs>32.6)
				level=12;
			else 
				level=0;
			return level;
		}
		else
			return "";
	};
	WindUtil.coverWindDesc = function(wd) {
		var temp = wd.replace(/风/g, ''), sign = '_';
		temp = temp.split('_');
		if (temp.length === 1) {
			temp = temp[0].split('转');
			sign = '转';
		}
		if (temp.length < 2) 
			return wd;
		if (temp[0].indexOf(temp[1]) != -1 || temp[1].indexOf(temp[0]) != -1)
			wd = wd.replace(sign, '到');
		else
			wd = wd.replace(sign, '转');
		return wd;
	};
	WindUtil.getWindConcat = function(wd) {
		var temp = wd.replace(/风/g, '');
		temp = temp.split('_');
		if (temp[0].indexOf(temp[1]) != -1 || temp[1].indexOf(temp[0]) != -1)
			wd = '到';
		else
			wd = '转';
		return wd;
	};
	window.WindUtil = WindUtil;
})()